﻿<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>jQuery子元素过滤器:only-child示例</title>
        <script src="js/jquery-3.6.1.min.js"></script>
		<style>
		ul{
			width:150px;
			border:1px solid;
			float:left;
			margin:10px;
		}
		</style>
    </head>
    <body>
        <h3>jQuery子元素过滤器:only-child示例</h3>
        <hr>
		<ul>
		    <li>Apple</li>
			<li>Pear</li>
			<li>Strawberry</li>
		</ul>
		<ul>
		    <li>Bread</li>
		</ul>
		<ul>
		    该ul元素内部无子元素。
		</ul>
        <script>
            $(document).ready(function() {
				//选择唯一的子元素li
                $("ul li:only-child").css("color","red");
            });
        </script>
    </body>
</html>